package com.qiwx.pigeon.fragment.produce;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.qiwx.pigeon.R;
import com.qiwx.pigeon.Utils.DBSqlUtil;
import com.qiwx.pigeon.Utils.DateTimeUtils;
import com.qiwx.pigeon.Utils.LogUtil;
import com.qiwx.pigeon.Utils.MyToast;
import com.qiwx.pigeon.activity.MainActivity;
import com.qiwx.pigeon.activity.produce.AddLayEggDateProduceActivity;
import com.qiwx.pigeon.adapter.produce.CheckEggAdapter;
import com.qiwx.pigeon.base.Constant;
import com.qiwx.pigeon.data.CageStatusConfig;
import com.qiwx.pigeon.data.params.CageAdjustParam;
import com.qiwx.pigeon.data.params.CageParam;
import com.qiwx.pigeon.data.params.CheckEggParam;
import com.qiwx.pigeon.data.params.FertilizeParam;
import com.qiwx.pigeon.data.params.LoseEggParam;
import com.qiwx.pigeon.data.vo.CageBeanVo;
import com.qiwx.pigeon.data.vo.CageRepairBean;
import com.qiwx.pigeon.data.vo.CageStatusRecordBean;
import com.qiwx.pigeon.data.vo.EliminateBean;
import com.qiwx.pigeon.data.vo.FertilizeBean;
import com.qiwx.pigeon.data.vo.PairBean;
import com.qiwx.pigeon.data.vo.pageinfo.PageInfo;
import com.qiwx.pigeon.fragment.HomeFragment;
import com.qiwx.pigeon.helper.DialogHelper;
import com.qiwx.pigeon.presenter.CageRemindPresenter;
import com.qiwx.pigeon.viewinterface.ICageRemindView;
import com.qiwx.pigeon.widget.ArrowView;
import com.qiwx.pigeon.widget.CageAdjustOptionView;
import com.qiwx.pigeon.widget.CheckBabyOptionView;
import com.qiwx.pigeon.widget.CheckEggOptionView;
import com.qiwx.pigeon.widget.KWOptionView;
import com.qiwx.pigeon.widget.LoseEggOptionView;
import com.qiwx.pigeon.widget.itemderection.CustomGridItemDecoration;

import org.angmarch.views.NiceSpinner;

import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import butterknife.BindView;
import butterknife.OnClick;

import static com.qiwx.pigeon.activity.common.SelectDateActivity.REQUEST_CODE_END;
import static com.qiwx.pigeon.activity.common.SelectDateActivity.REQUEST_CODE_START;

/**
 * @description
 * @Author qiwx
 * @Date 2020-03-29 16:52
 * 查蛋工段
 **/
public class CheckEggOperationFragment extends OpreateFragment implements ICageRemindView {
    @BindView(R.id.spinner_wh)
    NiceSpinner spinnerWh;
    @BindView(R.id.txt_start_date)
    TextView txtStartDate;
    @BindView(R.id.txt_end_date)
    TextView txtEndDate;
    @BindView(R.id.btn_condition)
    Button btnCondition;
    @BindView(R.id.btn_query)
    Button btnQuery;
    @BindView(R.id.rel_query_tools_top)
    RelativeLayout relQueryToolsTop;
    @BindView(R.id.lin_query_tools_date)
    LinearLayout linQueryToolsDate;
    @BindView(R.id.txt_nodata)
    TextView txtNodata;
    @BindView(R.id.recyclerview)
    RecyclerView recyclerview;
    @BindView(R.id.lin_nodata)
    LinearLayout linNodata;
    @BindView(R.id.rel_nodata_recycleview)
    RelativeLayout relNodataRecycleview;
    @BindView(R.id.arrow_left)
    ArrowView arrowLeft;
    @BindView(R.id.txt_prepage)
    TextView txtPrepage;
    @BindView(R.id.txt_divider)
    TextView txtDivider;
    @BindView(R.id.txt_nextpage)
    TextView txtNextpage;
    @BindView(R.id.arrow_right)
    ArrowView arrowRight;
    @BindView(R.id.btn_opreation_ok)
    Button btnOpreationOk;
    @BindView(R.id.btn_opreation_add_date)
    Button btnOpreationAddDate;

    @BindView(R.id.kw_options)
    KWOptionView kwOptions;
    @BindView(R.id.check_egg_options)
    CheckEggOptionView checkEggOptions;
    @BindView(R.id.check_baby_options)
    CheckBabyOptionView checkBabyOptions;
    @BindView(R.id.lose_egg_options)
    LoseEggOptionView loseEggOptionView;//损失
    @BindView(R.id.cage_adjust_options)
    CageAdjustOptionView cageAdjustOptionView;
    @BindView(R.id.txt_all)
    TextView txtAll;

    int pageNo = 1;//页码
    int pageAll;//总页码
    int pageSize = 20;//每页显示10条记录
    int allNums = 0;//总共有多少条记录
    int produceStatus;//生产状态
    List<FertilizeBean> data = new ArrayList<>();
    CheckEggAdapter adapter;
    public int selectPos = -1;
    int beforeDays = 7;//默认查蛋日期距离今天天数
    String startDate = "";
    String endDate = "";
    long kw_after = 0;//设置成空窝六天内不能再出现在查蛋工段里
    String kw_after_value;
    CageRemindPresenter cageRemindPresenter;


    @Override
    public int getLayoutId() {
        return R.layout.fragment_check_egg;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }


    @Override
    public void initAfterOnCreate() {
        super.initAfterOnCreate();
        linNodata.setVisibility(View.GONE);
        initView();
        updateTime();
        initSpinner();
        reFresh();
        cageRemindPresenter = new CageRemindPresenter(new WeakReference(this));
    }


    private void updateTime() {
//        if (AppContext.isGoTimeByMinute) {
//            long current = DateTimeUtils.getCurrentStamp();
//           // kw_after_value = current - LAY_KW_AFTER * 1000 * 60;
//        } else {
//            Date d1 = DateTimeUtils.addDay(new Date(), -(int) LAY_KW_AFTER);
//            String d2 = DateTimeUtils.timeStamp2Date(d1.getTime());
//            kw_after_value = DateTimeUtils.addTimeSuffix(d2, false);
//        }
        startDate = txtStartDate.getText().toString();
        endDate = txtEndDate.getText().toString();
    }

    private void initView() {
        spinnerWh.setText("选择状态");
        btnQuery.setText("刷新");
        btnCondition.setVisibility(View.GONE);
        arrowLeft.changeArrowLeft();
        arrowRight.changeArrowRight();
        //查蛋页面默认查的是今天往前推7天
        long start = DateTimeUtils.addDay(new Date(), -beforeDays).getTime();
        long end = DateTimeUtils.getCurrentStamp();
        txtStartDate.setText(DateTimeUtils.timeStamp2Date(start));
        txtEndDate.setText(DateTimeUtils.timeStamp2Date(end));

        recyclerview.setLayoutManager(new GridLayoutManager(getActivity(), 5));
        recyclerview.addItemDecoration(new CustomGridItemDecoration(1));
        adapter = new CheckEggAdapter(R.layout.adapter_check_egg_list_item, data);
        recyclerview.setAdapter(adapter);
        adapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(@NonNull BaseQuickAdapter adapter, @NonNull View view, int position) {
                if (selectPos == position) {
                    showCageInfo(position);
                    return;
                }
                updateListSelected(position);
                selectPos = position;
            }
        });
        // loadData();
        initEvent();
    }

    //获取操作记录
    public void getCageStatusRecordList(FertilizeBean fertilizeBean) {
        mPresenter.getCageStatusRecord(fertilizeBean.getC_id(), fertilizeBean.getLay_egg_date());


    }

    public void showCageInfo(int pos) {

        getCageStatusRecordList(data.get(pos));

    }

    //是指成空窝
    public void setCageKW(int pos, FertilizeBean bean) {
        selectPos = pos;
        CageParam cageParam = new CageParam();
        cageParam.setC_id(bean.getC_id());
        cageParam.setLay_egg_date(bean.getLay_egg_date());
        cageParam.setOperate_user_id(Constant.USER_ID);
        mPresenter.updateCageKW(cageParam);
    }

    //设置此条下蛋记录为历史记录 并将鸽笼设置成空窝
    public void deleteCageRecord(int pos, FertilizeBean bean) {
        selectPos = pos;
        CageParam cageParam = new CageParam();
        cageParam.setC_id(bean.getC_id());
        cageParam.setLay_egg_date(bean.getLay_egg_date());
        cageParam.setOperate_user_id(Constant.USER_ID);
        mPresenter.deleteCageRecord(cageParam);

    }

    private void initEvent() {

    }

    //更新列表选择状态
    public void updateListSelected(int pos) {
        for (int i = 0; i < data.size(); i++) {
            if (pos == i) {
                data.get(i).setSelected(true);
            } else {
                data.get(i).setSelected(false);
            }
        }
        adapter.notifyDataSetChanged();
    }

    private void initSpinner() {
        Map<String, Integer> maps = CageStatusConfig.getProduceStatus();
        List<String> data = new ArrayList<>();
        for (String v : maps.keySet()) {
            data.add(v);
        }
        spinnerWh.attachDataSource(data);
        spinnerWh.setOnSpinnerItemSelectedListener((parent, view, position, id) -> {
            LogUtil.e("TAG", data.get(position));
            produceStatus = maps.get(data.get(position));
            chageToolsShowState(produceStatus);
            reFresh();
        });
        //查蛋模块先查有蛋状态
        Bundle bundle = getArguments();
        if (bundle != null) {
            produceStatus = bundle.getInt("produce_status");
        }
        if (produceStatus == CageStatusConfig.PRODUCE_TW) {
            spinnerWh.setSelectedIndex(7);
            produceStatus = maps.get(data.get(7));
        } else if (produceStatus == CageStatusConfig.PRODUCE_CZ) {
            spinnerWh.setSelectedIndex(4);
            produceStatus = maps.get(data.get(4));
        } else {
            spinnerWh.setSelectedIndex(2);
            produceStatus = maps.get(data.get(2));
        }
        chageToolsShowState(produceStatus);

    }

    @Override
    public void onResume() {
        super.onResume();
//        reFresh();
    }

    public void setAdjust() {
        produceStatus = CageStatusConfig.PRODUCE_TW;
        spinnerWh.setSelectedIndex(7);
        chageToolsShowState(produceStatus);
        reFresh();
    }

    public void setCd() {
        produceStatus = CageStatusConfig.PRODUCE_CD;
        spinnerWh.setSelectedIndex(2);
        chageToolsShowState(produceStatus);
        reFresh();
    }

    public void setCz() {
        produceStatus = CageStatusConfig.PRODUCE_CZ;
        spinnerWh.setSelectedIndex(4);
        chageToolsShowState(produceStatus);
        reFresh();
    }

    @Override
    public void onReFreshData() {
        if (mPresenter == null)
            return;
        reFresh();
    }

    public void reFresh() {
        if (mPresenter == null)
            return;
        pageNo = 1;
        allNums = 0;
        selectPos = -1;
        goPageNew(1);
        //goPage(1);
    }

    //改变顶部工具栏显示内容
    public void chageToolsShowState(int produceStatus) {

        switch (produceStatus) {
            case CageStatusConfig.PRODUCE_KW:
                linQueryToolsDate.setVisibility(View.GONE);
                checkBabyOptions.setVisibility(View.GONE);
                checkEggOptions.setVisibility(View.GONE);
                kwOptions.setVisibility(View.VISIBLE);
                btnOpreationAddDate.setVisibility(View.GONE);
                loseEggOptionView.setVisibility(View.GONE);
                btnOpreationOk.setVisibility(View.VISIBLE);
                cageAdjustOptionView.setVisibility(View.GONE);
                break;

            case CageStatusConfig.PRODUCE_CD:
                checkEggOptions.reSetOptions();
                linQueryToolsDate.setVisibility(View.VISIBLE);
                checkBabyOptions.setVisibility(View.GONE);
                checkEggOptions.setVisibility(View.VISIBLE);
                kwOptions.setVisibility(View.GONE);
                btnOpreationAddDate.setVisibility(View.GONE);
                loseEggOptionView.setVisibility(View.GONE);
                btnOpreationOk.setVisibility(View.VISIBLE);
                cageAdjustOptionView.setVisibility(View.GONE);
                break;
            case CageStatusConfig.PRODUCE_YD://孵蛋和有蛋状态下可以操作损失
            case CageStatusConfig.PRODUCE_FD:
                linQueryToolsDate.setVisibility(View.VISIBLE);
                loseEggOptionView.setVisibility(View.VISIBLE);
                checkBabyOptions.setVisibility(View.GONE);
                checkEggOptions.setVisibility(View.GONE);
                kwOptions.setVisibility(View.GONE);
                btnOpreationAddDate.setVisibility(View.GONE);
                btnOpreationOk.setVisibility(View.VISIBLE);
                cageAdjustOptionView.setVisibility(View.GONE);
                break;
            case CageStatusConfig.PRODUCE_CZ:
            case CageStatusConfig.PRODUCE_CZ2:
                checkBabyOptions.resetOptions();
                linQueryToolsDate.setVisibility(View.VISIBLE);
                checkBabyOptions.setVisibility(View.VISIBLE);
                checkEggOptions.setVisibility(View.GONE);
                kwOptions.setVisibility(View.GONE);
                btnOpreationAddDate.setVisibility(View.GONE);
                loseEggOptionView.setVisibility(View.GONE);
                btnOpreationOk.setVisibility(View.VISIBLE);
                cageAdjustOptionView.setVisibility(View.GONE);

                break;
            case CageStatusConfig.PRODUCE_CK://查乳鸽
                linQueryToolsDate.setVisibility(View.VISIBLE);
                checkBabyOptions.setVisibility(View.GONE);
                checkEggOptions.setVisibility(View.GONE);
                kwOptions.setVisibility(View.GONE);
                btnOpreationAddDate.setVisibility(View.GONE);
                btnOpreationOk.setVisibility(View.GONE);
                loseEggOptionView.setVisibility(View.GONE);
                cageAdjustOptionView.setVisibility(View.GONE);
                break;
            case CageStatusConfig.PRODUCE_TW://调窝
                cageAdjustOptionView.setVisibility(View.VISIBLE);
                linQueryToolsDate.setVisibility(View.GONE);
                checkBabyOptions.setVisibility(View.GONE);
                checkEggOptions.setVisibility(View.GONE);
                kwOptions.setVisibility(View.GONE);
                btnOpreationAddDate.setVisibility(View.GONE);
                btnOpreationOk.setVisibility(View.VISIBLE);
                loseEggOptionView.setVisibility(View.GONE);
                break;

        }
    }

    public void goPageNew(int index) {
        CheckEggParam param = new CheckEggParam();
        param.setWh_id(MainActivity.wh_id);
        param.setPageSize(pageSize);
        param.setPageNum(index);
        param.setStartDate(startDate);
        param.setEndDate(endDate);
        if (produceStatus == CageStatusConfig.PRODUCE_TW) {
            loadDataAdjust(param);
        } else {
            loadDataCD(param);
        }


    }

    //查蛋相关
    private void loadDataCD(CheckEggParam param) {
        param.setProduce_status(produceStatus);
        param.setStatus(CageStatusConfig.STATUS_YGYM);
        mPresenter.getCheckEggListByPage(param);
    }

    //调窝
    private void loadDataAdjust(CheckEggParam param) {
        param.setProduce_status(produceStatus);
        param.setStatus(CageStatusConfig.STATUS_YGYM);
        mPresenter.getCageAdjustListByPage(param);
    }

    private void goPage(int index) {
        selectPos = -1;
        goPageNew(index);
    }

    @Override
    protected void onSelectDate(int type, String content) {
        if (type == 0) {
            startDate = content;
            txtStartDate.setText(startDate);
        } else {
            endDate = content;
            txtEndDate.setText(endDate);
        }
    }

    //空窝时下蛋 操作
    public void opreateLayEgg(int pos, FertilizeBean model) {
        int egg_status = DBSqlUtil.getFerilizeStatusByTpye(0);

        FertilizeParam param = kwOptions.getParam();
        param.setWh_id(MainActivity.wh_id);
        param.setNumber(model.getC_number());
        param.setEgg_status(egg_status);

        mPresenter.saveLayEgg(param);

    }


    @Override
    public void onHiddenChanged(boolean hidden) {
        super.onHiddenChanged(hidden);
        if (hidden) {
            //reFresh();
        }
    }

    //查蛋时操作
    public void opreateCheckEgg(int pos, FertilizeBean model) {
        FertilizeParam param = checkEggOptions.getParam(model.getAmount());
        param.setWh_id(MainActivity.wh_id);
        param.setNumber(model.getC_number());
        param.setC_id(model.getC_id());
        param.setLay_egg_date(model.getLay_egg_date());
        mPresenter.updateCheckEggStatus(param);
    }

    //查崽时操作
    public void opreateCheckBaby(int pos, FertilizeBean model) {
        selectPos = pos;
        if (model != null) {
            FertilizeParam param = checkBabyOptions.getParam(model.getAmount());
            param.setC_id(model.getC_id());
            param.setNumber(model.getC_number());
            param.setWh_id(MainActivity.wh_id);
            param.setLay_egg_date(model.getLay_egg_date());
            cageRemindPresenter.updateCageCZ(param);
        }
    }

    //有蛋和孵蛋损失
    public void operateLose(int pos, FertilizeBean model) {
        LoseEggParam param = loseEggOptionView.getParam();
        param.setWh_id(MainActivity.wh_id);
        param.setC_id(model.getC_id());
        param.setC_number(model.getC_number());
        param.setAdd_date(DateTimeUtils.getCurrentDateStr());
        if (model.getAmount() < param.getAmount()) {
            MyToast.showLong("鸽笼存蛋数不可以小于损失数!");
            return;
        }
        mPresenter.addEggLose(param);
    }

    //调窝
    public void adjustPigeon(int pos, FertilizeBean model) {
        CageAdjustParam param = cageAdjustOptionView.getParam();
        param.setWh_id(MainActivity.wh_id);
        param.setC_id(model.getC_id());
        param.setId(model.getId());
        param.setC_number(model.getC_number());
        mPresenter.adjustPigeon(param);
    }


    //确认操作
    public void save() {
        if (selectPos >= 0 && selectPos < data.size()) {
            FertilizeBean fertilizeBean = data.get(selectPos);
            if (fertilizeBean != null) {
                switch (produceStatus) {
                    case CageStatusConfig.PRODUCE_KW:
                        opreateLayEgg(selectPos, fertilizeBean);
                        break;
                    case CageStatusConfig.PRODUCE_CD:
                        opreateCheckEgg(selectPos, fertilizeBean);
                        break;
                    case CageStatusConfig.PRODUCE_CZ:
                    case CageStatusConfig.PRODUCE_CZ2:
                        opreateCheckBaby(selectPos, fertilizeBean);
                        break;
                    case CageStatusConfig.PRODUCE_YD:
                    case CageStatusConfig.PRODUCE_FD:
                        operateLose(selectPos, fertilizeBean);
                        break;
                    case CageStatusConfig.PRODUCE_TW:
                        adjustPigeon(selectPos, fertilizeBean);
                        break;
                }
            } else {
                MyToast.showLong("请选择鸽笼！");
            }
        } else {
            MyToast.showLong("请选择鸽笼！");
        }
    }

    //跳转补录下蛋日期
    private void goAddLayEggDate() {
        Intent go = new Intent();
        go.setClass(getActivity(), AddLayEggDateProduceActivity.class);
        if (selectPos >= 0 && selectPos < data.size()) {
            go.putExtra(Constant.INTENT_C_ID, data.get(selectPos).getId());
            go.putExtra(Constant.INTENT_C_NUMBER, data.get(selectPos).getC_number());
        }
        go.putExtra(Constant.INTENT_WH_ID, MainActivity.wh_id);
        go.putExtra(Constant.INTENT_WH_NUMBER, MainActivity.wh_number);

        startActivity(go);
    }

    @OnClick({R.id.txt_start_date, R.id.txt_end_date, R.id.btn_query, R.id.btn_opreation_ok, R.id.btn_opreation_add_date, R.id.arrow_left, R.id.arrow_right})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.txt_start_date:
                selectDate("2018-01", 0);
//                selectStartValiDate();
                break;
            case R.id.txt_end_date:
                selectDate(startDate, 1);

//                selectEndValiDate(txtStartDate.getText().toString());
                break;
            case R.id.btn_query:
                updateTime();
                goPage(1);
                break;
            case R.id.btn_opreation_ok:
                save();
                break;
            case R.id.btn_opreation_add_date:
                goAddLayEggDate();
                break;
            case R.id.arrow_left:
                if (pageNo == 1) {
                    MyToast.showShort("已经是第一页");
                } else {
                    pageNo = pageNo - 1;
                    goPage(pageNo);
                    txtPrepage.setText(pageNo + "");

                }
                break;
            case R.id.arrow_right:
                if (pageNo == pageAll) {
                    MyToast.showShort("已经是最后一页");
                } else {
                    pageNo = pageNo + 1;
                    goPage(pageNo);
                    txtPrepage.setText(pageNo + "");

                }

                break;
        }
    }

    private void initPageInfo() {
        pageAll = allNums / pageSize;
        if (allNums % pageSize != 0) {
            pageAll += 1;
        }
        txtPrepage.setText((pageAll == 0 ? 0 : pageNo) + "");
        txtNextpage.setText(pageAll + "");
    }

    @Override
    public void onCheckEggSuccess(PageInfo<FertilizeBean> beanPageInfo) {
        super.onCheckEggSuccess(beanPageInfo);

        if (beanPageInfo != null) {
            allNums = beanPageInfo.getTotal();
            initPageInfo();
            data.clear();
            data.addAll(beanPageInfo.getList());
        }
        adapter.notifyDataSetChanged();

        if (data.size() > 0) {
            txtNodata.setVisibility(View.GONE);
            linNodata.setVisibility(View.GONE);
            recyclerview.setVisibility(View.VISIBLE);
        } else {
            txtNodata.setVisibility(View.GONE);
            linNodata.setVisibility(View.GONE);
            recyclerview.setVisibility(View.VISIBLE);
        }
        txtAll.setText("总数：" + allNums);
    }

    private void updateAdapter() {
        if (selectPos >= 0 && selectPos < data.size()) {
            data.remove(selectPos);
            if (adapter != null) {
                adapter.notifyDataSetChanged();
                selectPos = -1;
                --allNums;
                txtAll.setText("总数：" + allNums);
            }

        }
    }

    @Override
    public void onSaveLayEggSuccess(int c_id) {
        super.onSaveLayEggSuccess(c_id);
        updateAdapter();
        kwOptions.resetOptions();
    }

    @Override
    public void onFailed(String error) {
        super.onFailed(error);
        data.clear();
        adapter.notifyDataSetChanged();

    }

    @Override
    public void onQueryCageSuccess(PageInfo<CageBeanVo> bean) {

    }

    @Override
    public void onQueryPairCageSuccess(PageInfo<PairBean> bean) {

    }

    @Override
    public void onQueryCageRepairSuccess(PageInfo<CageRepairBean> bean) {

    }

    @Override
    public void onQueryEliminateBeanSuccess(PageInfo<EliminateBean> bean) {

    }

    @Override
    public void onUpdateCageStatusSuccess(int type) {
        updateAdapter();
        checkBabyOptions.resetOptions();
    }

    @Override
    public void onQueryCateStatusRecordSuccess(List<CageStatusRecordBean> list) {
        if (list == null)
            return;
        DialogHelper.showCageInfoDialog(getActivity(), data.get(selectPos), list, new DialogHelper.ICheckEggInterface() {
            @Override
            public void onSelectStatus(FertilizeParam param, int status) {
                FertilizeBean bean = data.get(selectPos);
                if (bean.getProduce_status() == CageStatusConfig.PRODUCE_YD ||
                        bean.getProduce_status() == CageStatusConfig.PRODUCE_FD
                ) {
                    if (status == 0) {
                        deleteCageRecord(selectPos, bean);
                    } else {
                        setCageKW(selectPos, bean);

                    }

                }


            }
        });

    }

    @Override
    public void onAddOperate(int type) {
        updateAdapter();
        if (type == UPDATE_CHECK_EGG) {
            checkEggOptions.reSetOptions();
        }
        if (type == UPDATE_ADJUST) {
            cageAdjustOptionView.resetOptions();
        }
        if (type == ADD_TYPE_BFD_BROKEN) {
            loseEggOptionView.resetOptions();
        }

    }

    @Override
    public void onFailure(String error) {

    }
}
